wayland: Add support for show_window_menu
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 24 May 2014 03:01:27 +0000 (23:01 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Sat, 24 May 2014 19:55:55 +0000 (15:55 -0400)
gdk/wayland/gdkwindow-wayland.c
gdk/wayland/protocol/xdg-shell.xml

index 7f67e1be8561511484beb652d8a4ebcf978eba8f..14ffc5706b8763edce1da04bea0bc6d44e5b4dbb 100644 (file)
@@ -1934,6 +1934,40 @@ gdk_wayland_window_set_shadow_width (GdkWindow *window,
   gdk_wayland_window_sync_margin (window);
 }
 
+static gboolean
+gdk_wayland_window_show_window_menu (GdkWindow *window,
+                                     GdkEvent  *event)
+{
+  GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
+  GdkEventButton *event_button = (GdkEventButton *) event;
+  struct wl_seat *seat;
+  double x, y;
+  GdkWaylandDeviceData *device;
+
+  switch (event->type)
+    {
+    case GDK_BUTTON_PRESS:
+    case GDK_BUTTON_RELEASE:
+      break;
+    default:
+      return FALSE;
+    }
+
+  if (!impl->xdg_surface)
+    return FALSE;
+
+  seat = gdk_wayland_device_get_wl_seat (event_button->device);
+  device = wl_seat_get_user_data (seat);
+
+  gdk_event_get_coords (event, &x, &y);
+
+  xdg_surface_show_window_menu (impl->xdg_surface,
+                                seat,
+                                _gdk_wayland_device_get_button_press_serial (device),
+                                x, y);
+  return TRUE;
+}
+
 static void
 _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
 {
@@ -2023,6 +2057,7 @@ _gdk_window_impl_wayland_class_init (GdkWindowImplWaylandClass *klass)
   impl_class->get_scale_factor = gdk_wayland_window_get_scale_factor;
   impl_class->set_opaque_region = gdk_wayland_window_set_opaque_region;
   impl_class->set_shadow_width = gdk_wayland_window_set_shadow_width;
+  impl_class->show_window_menu = gdk_wayland_window_show_window_menu;
 }
 
 void
index 3c186102bba327c09d5c1d59480fd49240ba9429..28add4054cac3085d0e8627838d2f30e79eebc9a 100644 (file)
       <arg name="app_id" type="string"/>
     </request>
 
+    <request name="show_window_menu">
+      <description summary="show the window menu">
+        Clients implementing client-side decorations might want to show
+        a context menu when right-clicking on the decorations, giving the
+        user a menu that they can use to maximize or minimize the window.
+
+        This request asks the compositor to pop up such a window menu at
+        the given position, relative to the parent surface. There are
+        no guarantees as to what the window menu contains.
+
+        Your surface must have focus on the seat passed in to pop up the
+        window menu.
+      </description>
+
+      <arg name="seat" type="object" interface="wl_seat" summary="the seat to pop the window up on"/>
+      <arg name="serial" type="uint" summary="serial of the event to pop up the window for"/>
+      <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
+      <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
+    </request>
+
     <request name="move">
       <description summary="start an interactive move">
        Start a pointer-driven move of the surface.